#pragma once

#include <vector>
#include <set>
#include <queue>
#include <string>
#include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/Instructions.h"
#include "MemoryProfiler.h"
#include <sys/types.h>
#include <sys/mman.h>
#include <syslog.h>
#include "Utils.h"

using namespace llvm;
using namespace std;

struct PrefetchProfiler
{
	PrefetchProfiler(LoadInst *Inst, void*) : Inst(Inst)
	{
	}

	void Profile(void *Addr)
	{
		if (!isCached(Addr))
		{
//			syslog(LOG_ERR, "PREFETCH %p", Addr);
			if (madvise((void*) ((unsigned long) Addr & ~4095), 4096, MADV_WILLNEED) != 0)
				errs() << "madvise error\n";
		}

	}

	LoadInst *Inst;
};
